package com.web;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.LeaveDTO;
import bizlogic.LeaveManager;

/**
 * @Thiri
 * Servlet implementation class DetailLeaveViewServlet
 */
@WebServlet("/DetailLeaveViewServlet")
public class DetailLeaveViewServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DetailLeaveViewServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request,response);
	}
	
	protected void  doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		    String id = request.getParameter("id"); 
			/*UserManager um = new UserManager();
			LeaveManager lm=new LeaveManager();
			UserDTO manager = um.findUser(id);
			ArrayList<LeaveDTO> data = new ArrayList<LeaveDTO>();
			
			data = um.findAllLeaveByManagerId(manager);*/
		     
			LeaveManager lm=new LeaveManager();
			LeaveDTO data = lm.findLeaveDetailByID(id);
			
			
		    request.setAttribute("employee", data);
			RequestDispatcher rd = request.getRequestDispatcher("DetailLeaveView.jsp");
			rd.forward(request, response);
			
	}

}
